import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { officeTreeData } from '/@/api/sys/office';
import { companyTreeData } from '/@/api/sys/company';
import { basCusListData } from '/@/api/bas/cus/basCus';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('市级代理选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 100,
  schemas: [
    {
      label: t('客户编码'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('客户名称'),
      field: 'name',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('客户编码'),
    dataIndex: 'code',
    key: 'a.code',
    sorter: true,
    width: 100,
    // slot: 'firstColumn',
  },
  {
    title: t('客户名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 100,
  },
];

const tableProps: BasicTableProps = {
  api: basCusListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    // params['cusDefine2'] = '市代旗舰店';
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'code',
};

const treeProps: Recordable = {
  api: officeTreeData,
  params: { isAll: true },
  title: t('机构'),
};

const treeTableFieldName = 'employee.office.officeCode';

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'name',
  isShowCode: true,
  // treeProps,
  treeTableFieldName,
};
